package com.keyue.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author: xms
 * @description: TODO
 * @date: 2023/9/13 18:05
 * @version: 1.0
 */
@Getter
@AllArgsConstructor
public enum RoleEnum {

    ADMIN("admin", 1L, "超级管理员"),
    BUSINESS_USER("business_user", 2L, "业务员"),
    TRACKER_USER("tracker_user", 3L, "跟单员"),
    INSPECT_USER("inspect_user", 4L, "质检员"),
    DATA_REPORT_USER("data_report_user", 5L, "数据分析员"),
    PRODUCE_USER("produce_user", 6L, "生产科"),
    ;
    private String code;

    private Long id;

    private String name;


    /**
     *
     * @param id
     * @return
     */
    public static String getCodeById(Long id) {
        RoleEnum[] roleEnums = RoleEnum.values();
        for (RoleEnum roleEnum : roleEnums) {
            if (roleEnum.id.equals(id)) {
                return roleEnum.getCode();
            }
        }
        return null;
    }

    /**
     *
     * @param id
     * @return
     */
    public static String getNameById(Long id) {
        RoleEnum[] roleEnums = RoleEnum.values();
        for (RoleEnum roleEnum : roleEnums) {
            if (roleEnum.id.equals(id)) {
                return roleEnum.getName();
            }
        }
        return null;
    }
}
